package com.sfzlot.dev.netty.bean.data.powerswitch;

import java.util.Date;

import com.sfzlot.dev.netty.bean.inf.Data;
import com.sfzlot.dev.netty.utils.ByteUtil;

/**
 * 设备基本信息应答体
 * Created by pierr on 2017/5/30.
 */
public class PowerSwitchInfoOutData implements Data {
    
    private Date dataCollectTime;	// 数据采集时间
    private String ssid;			// wifi名称
    private String password;		// wifi密码
    private int status;				// 设备状态
    private int times;				// 状态时间
    private int flag;				// 通电开关 0-关；1-开 

    public Date getDataCollectTime() {
        return dataCollectTime;
    }

    public void setDataCollectTime(Date dataCollectTime) {
        this.dataCollectTime = dataCollectTime;
    }

	public String getSsid() {
		return ssid;
	}

	public void setSsid(String ssid) {
		this.ssid = ssid;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getTimes() {
		return times;
	}

	public void setTimes(int times) {
		this.times = times;
	}

	public int getFlag() {
		return flag;
	}

	public void setFlag(int flag) {
		this.flag = flag;
	}


	@Override
	public String toString() {
		return "DeviceInfoOutData [dataCollectTime=" + dataCollectTime + ", ssid=" + ssid + ", password=" + password
				+ ", status=" + status + ", times=" + times + ", flag=" + flag + "]";
	}

	@Override
	public byte[] toBytes(){
		byte[] dateBytes = ByteUtil.timeToBytes(dataCollectTime);
		byte[] ssidBytes = ByteUtil.stringToByte(ssid, 32);
		byte[] passwordBytes = ByteUtil.stringToByte(password, 32);
		byte[] statusBytes = new byte[1];
		statusBytes[0] = Integer.valueOf(status).byteValue();
		byte[] timesBytes = ByteUtil.int2bytes(times);
		byte[] flagByte = new byte[1];
		flagByte[0] = Integer.valueOf(flag).byteValue();
		return ByteUtil.addAll(dateBytes, ssidBytes, passwordBytes, statusBytes, timesBytes, flagByte);
	}

	@Override
	public String transData() {
		return "DeviceInfoOutData [dataCollectTime=" + dataCollectTime + ", ssid=" + ssid + ", password=" + password
				+ ", status=" + status + ", times=" + times + ", flag=" + flag + "]";
	}
}
